package com.purong.purong.util;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by zwj on 2016/2/23.
 */
public class SharePreUtil {
    private static SharePreUtil instance;
    private SharedPreferences sp;
    private SharedPreferences.Editor editor;
    private SharePreUtil(Context context){
        sp=context.getSharedPreferences("zuitese",Context.MODE_PRIVATE);
        editor=sp.edit();
    }
    public static SharePreUtil getInstance(Context context){
      if (instance==null){
          instance=new SharePreUtil(context);
      }
        return instance;
    }
    public void setLoactionAreaName(String name){
        editor.putString("LOCATION_AREA_NAME",name);
        editor.commit();
    }
    public String getLoactionAreaName(){
        String name=sp.getString("LOCATION_AREA_NAME",null);
        return name==null?"北京":name;
    }
    public void setLoactionAreaId(String id){
        editor.putString("LOCATION_AREA_ID",id);
        editor.commit();
    }
    public String getLoactionAreaId(){
        String id=sp.getString("LOCATION_AREA_ID",null);
        return id==null?"2":id;
    }
    public void setLoactionParentId(String id){
        editor.putString("LOCATION_PARENT_ID",id);
        editor.commit();
    }
    public String getLoactionParentId(){
        String id=sp.getString("LOCATION_PARENT_ID",null);
        return id==null?"1":id;
    }
    public void setTokenTime(long tokenTime){
        editor.putLong("TOKEN_TIME",tokenTime);
        editor.commit();
    }
    public long getTokentTime(){
        return sp.getLong("TOKEN_TIME",0);
    }
    public void setToken(String token){
        editor.putString("TOKEN",token);
        editor.commit();
    }
    public String getToken(){
        return sp.getString("TOKEN",null);
    }
    public void setRecommedTime(long date){
        editor.putLong("RECOMMED_TIME",date);
        editor.commit();
    }
    public long getVideoTime(){
        return sp.getLong("VIDEO_TIME",-1);
    }
    public void setVideoTime(long date){
        editor.putLong("VIDEO_TIME",date);
        editor.commit();
    }
    public long getRecommedTime(){
        return sp.getLong("RECOMMED_TIME",-1);
    }
    public void setImageTime(long date){
        editor.putLong("IMAGE_TIME",date);
        editor.commit();
    }
    public long getImageTime(){
        return sp.getLong("IMAGE_TIME",-1);
    }
    public void setJokeTime(long date){
        editor.putLong("JOKE_TIME",date);
        editor.commit();
    }
    public long getJokeTime(){
        return sp.getLong("JOKE_TIME",-1);
    }
    public long getJokeCircleTime(){
        return sp.getLong("JOKE_CIRCLE_TIME",-1);
    }
    public void setJokeCircleTime(long date){
        editor.putLong("JOKE_CIRCLE_TIME",date);
        editor.commit();
    }
    public long getBizCircleTime(){
        return sp.getLong("BIZ_CIRCLE_TIME",-1);
    }
    public void setBizCircleTime(long date){
        editor.putLong("BIZ_CIRCLE_TIME",date);
        editor.commit();
    }
//    public void setOrderAll(String url){
//        editor.putString("ORDER_All",url);
//        editor.commit();
//    }
//    public String getOrderAll(){
//        return sp.getString("ORDER_All","");
//    }
//    public void setOrderPay(String url){
//        editor.putString("ORDER_PAY",url);
//        editor.commit();
//    }
//    public String getOrderPay(){
//        return sp.getString("ORDER_PAY","");
//    }
//    public void setOrderSend(String url){
//        editor.putString("ORDER_SEND",url);
//        editor.commit();
//    }
//    public String getOrderSend(){
//        return sp.getString("ORDER_SEND","");
//    }
//    public void setOrderReceive(String url){
//        editor.putString("ORDER_RECEIVE",url);
//        editor.commit();
//    }
//    public String getOrderReceive(){
//        return sp.getString("ORDER_RECEIVE","");
//    }
//    public void setOrderSale(String url){
//        editor.putString("ORDER_SALE",url);
//        editor.commit();
//    }
//    public String getOrderSale(){
//        return sp.getString("ORDER_SALE","");
//    }
//    public void setCart(String url){
//        editor.putString("CART",url);
//        editor.commit();
//    }
//    public String getCart(){
//        return sp.getString("CART","");
//    }
    public void setNewFriends(int count){
        editor.putInt("NEW_FRIENDS",count);
        editor.commit();
    }
    public int getNewFriends(){
        return sp.getInt("NEW_FRIENDS",0);
    }
    public void setNoticeCount(int count){
        editor.putInt("NOTICE_COUNT",count);
        editor.commit();
    }
    public int getNoticeCount(){
        return sp.getInt("NOTICE_COUNT",0);
    }
    public void setShowIntroduce(boolean isShow){
        editor.putBoolean("SHOW_INTRODUCE",isShow);
        editor.commit();
    }
    public boolean getShowIntroduce(){
        return sp.getBoolean("SHOW_INTRODUCE",true);
    }
}
